# -*- coding: utf-8 -*-
# @Time    : 2022/7/16 19:13
# @Author  : clm
# @Email   : 2894940379@qq.com
# @File    : email_login_page.py
# @Software: PyCharm
from selenium.webdriver.common.by import By
from pages.base_pageage import BasePage
class EmailLoginPage(BasePage):
    """登陆页面类"""
    url="http://localhost/crm/index.php?m=dynamic&a=index"
    username_locator=(By.NAME,'name')
    password_locator = (By.NAME,'password')
    login_btn_locator=(By.NAME,'submit')
    click_market_locator = (By.CSS_SELECTOR, "body > div.navbar.navbar-inverse.navbar-fixed-top > div > div > "
                                           "div.nav-collapse.collapse > ul:nth-child(1) > li:nth-child(3) > a")
    def input_username(self,username):
        """输入用户名"""
        self.driver.find_element(*self.username_locator).send_keys(username)
    def input_password(self,password):
        """输入密码"""
        self.driver.find_element(*self.password_locator).send_keys(password)

    def click_login(self):
        """输入密码"""
        self.driver.find_element(*self.login_btn_locator).click()

    def login_crm(self,username,password):
        """登录首页"""
        element = BasePage(self.driver)
        element.find(self.username_locator).send_keys(username)
        element.find(self.password_locator).send_keys(password)
        element.find(self.login_btn_locator).click()

    def click_market(self):
        """点击营销，进入营销页面"""
        self.driver.find_element(*self.click_market_locator).click()
